<?php
namespace Home\Model;
//物品基础属性
class City extends CityBase{
    protected $redis;
    protected $user;
    protected $username ;
    protected $city;
    public function initData(){
        $res = new \Home\Model\Resource($this->user);
        $res->initData();
        $this->join();
    }

    public function join(){
        $this->hSet('user_'.$this->username.'_join_ts', time());
        $this->hIncrBy('count', 1);
        $users = $this->getUsers();
        array_push($users, $this->username);
        $users = json_encode($users);
        $this->hSet('users', $users);
    }

    
    public function getUsers(){
        $users = $this->hGet('users');
        if(!$users){
            $users = array();
        }else{
            $users = json_decode($users, true);
        }
        return $users;
    }
} 